﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;

public class AttackFactory : MMSingleton<AttackFactory>
{
    public AttackInfo[] attackInfoArray;

    public IAttack GetAttack(int id)
    {
        AttackInfo attackInfo = GetAttackInfo(id);
        IAttack attack = GetComponent(attackInfo.attackLogicName) as IAttack;
        return attack;
    }
    /// <summary>
    /// 根据ID得到AttackInfo
    /// </summary>
    /// <param name="id">攻击的ID</param>
    /// <returns></returns>
    public AttackInfo GetAttackInfo(int id)
    {
        foreach (var i in attackInfoArray)
        {
            if (i.ID == id)
            {
                return i;
            }
        }
        return null;
    }
}
